package videoCourse.sort;

public class SelectSort {
    public static void main(String[] args) {
        int[] arr = {5,7,2,9,4,1,0,5,7};
        selectSort(arr);
        for(int i : arr){
            System.out.print(i+" ");
        }

    }
    private static void selectSort(int[] nums){
        for(int i = 0;i<nums.length-1;i++){
            int min = nums[i];
            int min_index = i;
            int j = i+1;
            for(;j<nums.length;j++){
                if(nums[j] < min){
                    min = nums[j];
                    min_index = j;
                }
            }
            int temp = nums[i];
            nums[i] = nums[min_index];
            nums[min_index] = temp;
        }
    }
}
